<template>
	<view style="padding: 20px;">
		<view style="width: 100%;display: flex;justify-content: center;">
			<image :src="'http://211.103.114.94:2081/camera/IoReadImageByPath?path='+deviceData.picUrl"
				style="width: 500rpx; height: 500rpx;"></image>
		</view>
		<view
			style="background-color: #fff;height: 100rpx;width: 100%;border-radius: 15rpx;margin-top: 40rpx;display: flex;">
			<view
				style="width: 50%;display: flex;flex-direction: column;justify-content: center;text-align: center;height: 100%;">
				<view style="color: #999;">设备名称：</view>
				<view>{{deviceData.productName}}</view>
			</view>
			<view
				style="width: 50%;display: flex;flex-direction: column;justify-content: center;text-align: center;height: 100%;">
				<view style="color: #999;">设备编号：</view>
				<view>{{deviceData.equipmentNum}}</view>
			</view>
		</view>
		<view
			style="background-color: #fff;height: auto;width: 100%;border-radius: 15rpx;margin-top: 40rpx;padding: 40rpx 80rpx;">
			<view>
				<view style="color: #999;">品牌：<span style="color: black;">{{deviceData.brand}}</span></view>
			</view>
			<view style="margin-top: 5rpx;">
				<view style="color: #999;">供应商：<span style="color: black;">{{deviceData.supplier}}</span></view>
			</view>
			<view style="margin-top: 5rpx;">
				<view style="color: #999;">出场日期：<span
						style="color: black;">{{changeTime(deviceData.produceDate)}}</span></view>
			</view>
			<view style="margin-top: 5rpx;">
				<view style="color: #999;">产地：<span style="color: black;">{{deviceData.madeIn}}</span></view>
			</view>
			<view style="margin-top: 5rpx;">
				<view style="color: #999;">出场日期：<span
						style="color: black;">{{changeTime(deviceData.produceDate)}}</span></view>
			</view>
		</view>

	</view>
</template>
<!-- craftName	String	工艺段名称
equipmentName	String	设备名称
productName	String	产品名称-购买名称
equipmentNum	String	设备编号
deviceType	String	设备大类
equipmentLevel	String	设备等级
madeIn	String	产地
produceDate	Date	出场日期
brand	String	品牌
supplier	String	供应商
flag	int	0:正常使用 1:备用 2:报废 3:库存
craftPic	String	设备对应二维码图片
picUrl	String	设备图片地址 -->
<script>
	import {
		queryCompanyCraftEquipmentByName
	} from "@/api/index"
	export default {
		data() {
			return {
				deviceData: {},
				name: null,
				device: null,
				form: {}
			}
		},
		onLoad: function(option) {
			console.info("-----111------", option)
			this.name = option.craftName;
			this.device = JSON.parse(option.item).name

		},
		onReady() {
			this.getServerData1();
		},
		methods: {
			getServerData1() {

				uni.showLoading({
					title: '加载中'
				});
				this.form.craftName = this.name
				queryCompanyCraftEquipmentByName(this.form).then(response => {
					// 使用示例
					var list = response;
					console.info('aaaaaaa', response)

					response.forEach((item) => {
						
						if (this.device === item.equipmentName) {console.info("aaaaaaaaaaaaaaaaaaa",item)
							this.deviceData = item
							
						}

					});
					console.info('aa2aaa', this.devicetData)
					this.isFinish = false
					console.log('上拉加载停止')
					uni.stopPullDownRefresh()
					setTimeout(function() {
						uni.hideLoading();
					}, 500);
				})

			},
			changeTime(e) {
				console.log(e);
				let date = new Date(e);
				let year = date.getFullYear();
				let month = (date.getMonth() + 1).toString().padStart(2, '0'); // 月份从0开始，需要加1，然后使用padStart方法补齐两位
				let day = date.getDate().toString().padStart(2, '0'); // 使用padStart方法补齐两位

				let formattedDate = `${year}-${month}-${day}`;
				console.log(formattedDate); // 输出格式化后的日期
				return formattedDate;
			}
		}
	}
</script>

<style>

</style>